How loud the music is playing right now, from 0 (silent) to 1 (full) - during a fade it falls to 0 and climbs back, one step a frame, exactly as it is heard.
music_volume() -> realreal
How loud the music is playing right now, as a number from 0 (silent) to 1 (full volume). It reads 0 when no music is playing at all - before the first song, after music_stop, or once a song that does not loop has finished.
Most of the time it just sits at the volume you asked for in music_play or music_fade_to. The interesting time is a fade. music_fade_to turns the old song down to 0 over 16 frames, then starts the new one at 0 and turns it up over about 24 frames, and music_volume follows every step of it. Draw it and you have a volume meter that moves exactly as the music is heard.
Why is there no "how far through the fade" number from 0 to 1? Because a fade is not always the same shape. It has two halves of different lengths. It can begin half way down: if you change your mind in the middle of a fade-out and ask for the old song back, it comes back up from wherever it had got to instead of going all the way to silence first. And it can end below 1, if you gave music_fade_to a quieter volume. One 0..1 figure could not mean the same thing in all of those, but the volume is exact in every one. Pair it with music_fading, which says whether a fade is going on, and you know both that the music is changing and how loud it is.
var cells = int_round(music_volume() * 8);
var meter = string_repeat("#", cells);
draw_text_anchored(ANCHOR_TOP_LEFT, 4, 4, meter);Turns the volume into a row of up to eight # marks - none for silence, eight at full volume - and writes it in the top-left corner. Press a button that calls music_fade_to and the row shrinks to nothing, then grows back as the new song comes up.
Reads 0 while no music is playing (never started, stopped, or a song that does not loop and has finished). There is deliberately no "how far through the fade" number: a fade has two halves of different lengths, can begin half way down when you change your mind in mid-fade, and can end below 1 (the volume you gave music_fade_to), so one 0..1 figure would not mean the same thing every time. The volume is exact in every case.